<script setup>
import { ref } from 'vue';

const props = defineProps({
    step : {
        type: Number,
        //required:true,
        default:1,
        validator : (value)=>{
            console.log("校验数据: ",value)
            if(value > 10){
                console.error("step参数不能大于10")
            }
            return value<=10
        }
    }
})

const emit = defineEmits(['cntChange'])

const cntVal = ref(0)

const plusStep = ()=>{
    cntVal.value += props.step
    emit('cntChange',"子组件调用参数")
}
</script>

<template>
    <div>
        <p>传递的参数是: {{ step }}</p>
        <button @click="plusStep">按钮点击次数:{{ cntVal }}</button>
    </div>
</template>

<style scoped>
    button{
        font-size: 20px;
        background-color: skyblue;
    }
</style>